package com.example.demo1.mapper;

import com.example.demo1.entity.BaUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface BaUserMapper {

    int deleteByPrimaryKey(Integer staffId);

    int insert(BaUser record);

    int insertSelective(BaUser record);

    BaUser selectByPrimaryKey(Integer userId);

    int updateByPrimaryKeySelective(BaUser record);

    int updateByPrimaryKey(BaUser record);

    // 用于登录用户名校验
    BaUser checkUserName(String userName);

    // 用于用户注册异步校验邮箱是否存在
    BaUser validateUserEmail(String userEmail);

    // 用于用户编辑异步校验邮箱是否存在
    BaUser validateUserEmailNotSelf(@Param("userEmail") String userEmail, @Param("staffId") Integer staffId);

    List<Map<String, Object>> selectUsersByUserNameForPT(@Param("userName") String userName);

    BaUser selectUserByUserName(String userName);

    BaUser selectUserByUserNameNotSelf(@Param("userName") String userName, @Param("staffId") Integer staffId);

    Integer selectUserRoleByUserId(@Param("userId") Integer userId) ;

    @Select("select count(1) from ba_user where company_id = #{companyId}")
    int qryUserCountByCompanyId(@Param("companyId") Integer companyId);

    @Select("select count(1) from ba_user where user_depart_id = #{departId}")
    int qryUserCountByDepartId(@Param("departId") Integer departId);

    List<BaUser> selectChildrenByUserId(@Param("parentUserId") String parentUserId,
                                         @Param("companyId") Integer companyId);

    List<BaUser> getUsersByDepartId(@Param("departId") Integer departId);

    List<BaUser> getUsersByDepartIdExSelf(@Param("userId") Integer userId, @Param("departId") Integer departId);

    List<BaUser> getDepartUsers(@Param("departId") Integer departId, @Param("companyId") Integer companyId);

    List<BaUser> oaAccountVolidate(@Param("oaAccount") String oaAccount);

    List<BaUser> oaAccountVolidateExSelf(@Param("userId") Integer userId, @Param("oaAccount") String oaAccount);

    BaUser selectByOaAccount(String oaAccount);

    Map<String, Object> getUserCenterInfo(@Param("userId") Integer userId);

    List<BaUser> listUserInfoByCompanyId(@Param("companyId") Integer companyId);

    List<String> selectByDepartIds(@Param("departIds") List<String> departIds);

}